✸ ✸ ✸
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>if</title>
</head>
<body>
<div id="vue-app">
<h1> 实例化多个对象</h1>
<div id="vue-app-one">
<p> {{ title }}</p>
<p> {{ greet }}</p>
</div>
<div id="vue-app-two">
<p> {{ title }}</p>
<p> {{ greet }}</p>
<button v-on:click="change">change one</button>
</div>
<script src="/static/js/vue.min.js"></script>
<script>
var one = new Vue({
el: "#vue-app-one",
data: {
title: "app-one"
},
methods: {},
computed: {
greet:function () {
return "computed app one"
}
}
});
var two = new Vue({
el: "#vue-app-two",
data: {
title: "app-two"
},
methods: {
change:function () {
one.title="changed app one"
}
},
computed: {
greet:function () {
return "computed app two"
}
}
});
two.title="changed app two";
</script>
</body>
</html>
✸ ✸ ✸
📜 版权声明
本文作者:王梓 | 原文链接:https://www.bthlt.com/note/6795339-CssJsHtmlvue.js 多个vue实例
出处:葫芦的运维日志 | 转载请注明出处并保留原文链接
📜 留言板
留言提交后需管理员审核通过才会显示